package com.hznu.jspFinal.service;



import com.hznu.jspFinal.dao.UserMapper;
import com.hznu.jspFinal.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService{

    @Autowired
    private UserMapper userMapper;

    @Override
    public void addOne(User user) {
        userMapper.insert(user);
    }

    @Override
    public User findByUserId(Integer id){
        return userMapper.selectByPrimaryKey(id);
    }

    @Override
    public void update(User user) {
        userMapper.updateByPrimaryKeySelective(user);
    }

    @Override
    public void delete(Integer id) {
        userMapper.deleteByPrimaryKey(id);
    }

    @Override
    public User findByUsername(String username)
    {
        return userMapper.selectByUsername(username);
    }

    @Override
    public List<User> findAll()
    {
        return userMapper.selectAll();
    }

    @Override
    public List<User> findBatchByCondition(User user)
    {
        return userMapper.selectBatchByCondition(user);
    }
}
